// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-10

#ifndef __SVR_USERPOOL_H_COMMON_SVR_BASE__
#define __SVR_USERPOOL_H_COMMON_SVR_BASE__

#pragma once

#include <common/base/thread.h>
#include "svr_userset.h"
#include "net_accept.h"

namespace JoyServer
{

class CJoyUser;
class CJoyUserPool;

class CJoyUserAcceptor : public CJoyAcceptorEx
{
protected:
    virtual bool OnAccept(SOCKET s, const sockaddr_in& addr);
public:
    CJoyUserPool*   m_userPool;

    CJoyUserAcceptor();
    virtual ~CJoyUserAcceptor();

};

class CJoyUserPool : public CJoyUserSet
{
public:
    friend class CJoyUserAcceptor;

    CJoyUserAcceptor*   m_acceptor;

    virtual CJoyUserAcceptor* AllocAcceptor();
    virtual bool OnAccept(SOCKET s, const sockaddr_in& addr);
public:
public:
    CJoyUserPool();
    virtual ~CJoyUserPool();

    virtual bool UserEnter(CJoyUser* pUser);
    virtual void UserLeave(CJoyUser* pUser);

    virtual bool Create(CJoyServer*);
    virtual void Destroy();
};

} // namespace JoyServer

#endif  // __SVR_USERPOOL_H_COMMON_SVR_BASE__